package com.yuejian_06.yuejian_06.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.yuejian_06.yuejian_06.Listener.MeListener;
import com.yuejian_06.yuejian_06.R;
import com.yuejian_06.yuejian_06.bean.UserInfoBean;
import com.yuejian_06.yuejian_06.model.MeModel;

public class UserinfoActivity extends BaseActivity {
    private TextView user_name;
    private TextView address;
    private TextView user_pwd;
    private TextView phonenum;
    private TextView createtime;
    private ImageView user_pic;
    private Button back_set;

    @Override
    void initViews() {

    }

    @Override
    void initEvents() {

    }

    @Override
    void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_userinfo);
        initView();//初始化事件
        initEvent();//监听
        MeModel meModel = new MeModel();
        meModel.getUserInfo(getUser_id(),meListener);
    }
    private void initView(){
        user_name = (TextView) findViewById(R.id.user_name);
        user_pwd = (TextView) findViewById(R.id.user_pwd);
        address = (TextView) findViewById(R.id.address);
        phonenum = (TextView) findViewById(R.id.phonenum);
        createtime = (TextView) findViewById(R.id.createtime);
        user_pic = (ImageView) findViewById(R.id.user_pic);
        back_set = (Button) findViewById(R.id.back_set);
    }
    private void initEvent(){
        back_set.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
    private MeListener<UserInfoBean> meListener =new MeListener<UserInfoBean>() {
        @Override
        public void onResponse(UserInfoBean o) {
            UserInfoBean res=o;
            user_name.setText(res.getUser_name());
            user_pwd.setText(res.getUser_pwd());
            address.setText(res.getAddress());
            phonenum.setText(res.getPhonenum());
            createtime.setText(res.getCreatetime());
            if (!"".equals(res.getUser_pic()))
                Picasso.with(UserinfoActivity.this).load("http://10.0.2.2/yuejian/Public/userpics/"+res.getUser_pic()).into(user_pic);

        }

        @Override
        public void onFail(String msg) {

        }
    };
}
